# -*-  coding:utf-8 -*-
from mcp.server.fastmcp import FastMCP
 
#DEAULT_TRANSPORT = "stdio"

DEAULT_TRANSPORT = "sse"

import mysqldo
import json
from fastapi.responses import PlainTextResponse

mcp = FastMCP("Demo")


@mcp.tool(name="add",description="两个数相乘的计算工具")
def add(a: int, b: int) -> int:
    """Add two numbers"""
    print("相乘工具")
    print(f'a: {a},b: {b}')
    return "12"



@mcp.tool(name="myadd",description="两个数相加的计算公式")
def myadd(a: int, b: int) -> int:
    """Add two numbers"""
    print("相加工具")
    print(f'a: {a},b: {b}')
    return {"result":12}
    


 
@mcp.tool()
async def machine(name:str,sbcode:str)->str:
    """服务器状态查询工具
       name:设备名称
       sbcode:设备编号
    """
    print("客户设备信息查询工具")
    print("{0}---".format("strName"))

    return "目前服务器运行特别正常"

    
    return "aaaaaaaaaaaaaaaaaaaaaaaa"

# Add a dynamic greeting resource
@mcp.resource(uri="greeting://",name="greeting")
def get_greeting() -> str:
    """Get a personalized greeting"""
    return f"Hello, world!"
 
@mcp.resource(uri="greeting://{name}",name="greeting")
def get_greeting(name: str) -> str:
    """Get a personalized greeting"""
    return f"Hello, {name}!"
 
@mcp.prompt()
def review_code(code: str) -> str:
    return f"Please review this code:\n\n{code}"
 
if __name__ == "__main__":

    print(f"start mcp server,transport: {DEAULT_TRANSPORT}...")  # 记录服务启动日志
    mcp.settings.port = 6000
    mcp.run(transport=DEAULT_TRANSPORT)